<?php
namespace app\client\controller;

use think\Url;
use think\Request;
use think\Session;
use think\Controller;
use app\client\model\ShopHome as ShopHomeModel;

class ShopHome extends Controller
{

    /*
     * 店铺首页信息
     */
    public function index()
    {

        if (Request::instance()->isPost()) {

            $data = Request::instance()->param();

            $find = (new ShopHomeModel())->where(['member_id' => Session::get('shop_id')])->value('member_id');

            if ($find) {
                // 提交数据
                $dispose = (new ShopHomeModel())->allowField(true)->save($data, ['member_id' => Session::get('shop_id')]);
            } else {
                // 数据
                $data['member_id'] = Session::get('shop_id');
                // 提交数据
                $dispose = (new ShopHomeModel())->allowField(true)->save($data);
            }


            if ($dispose) {
                win('操作成功', Url::build('Shop/index'));
            }

            fail('操作失败');

        }

    }
}
